Skip to content

Conversation

shadchin
Copy link
Contributor

If Py_DEBUG enabled, then newly allocated memory is filled with the byte 0xCD (CLEANBYTE) https://docs.python.org/3/c-api/memory.html#c.PyMem_SetupDebugHooks

This breaks checks for pointer == NULL and results in crash.

From documentation PyObject_GC_Track https://docs.python.org/3/c-api/gcsupport.html#c.PyObject_GC_Track

This should be called once all the fields followed by the tp_traverse handler become valid, usually near the end of the constructor.

Copy link
Member

@elprans elprans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks!

@elprans elprans merged commit a113d90 into MagicStack:master Apr 26, 2021
@shadchin shadchin deleted the patch-1 branch April 27, 2021 11:19
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants